package thread;

import java.util.concurrent.atomic.AtomicInteger;

public class demo12 {
    private static AtomicInteger count = new AtomicInteger(0);
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(() -> {
            for (int i = 0; i < 10000; i++) {
                //count++
                count.getAndIncrement();
            /*    //++count
                count.incrementAndGet()
                //count --
                count.getAndDecrement();
                //--count
                count.decrementAndGet();
                //count +=
                count.addAndGet(1);*/
            }

        });
        Thread t1 = new Thread(() -> {
            for (int i = 0; i < 10000; i++) {
                count.incrementAndGet();
            }

        });
        t.start();
        t1.start();
        t.join();
        t1.join();
        System.out.println(count.get());
    }
}


